-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Support scrolling with animation #4698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
39b0d30 to
ed26d30
Compare
b10e57d to
6af4ed5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements smooth scrolling animation support for Quill's scrollRectIntoView() and scrollSelectionIntoView() methods, similar to the native Element.scrollIntoView() API. The changes also include upgrades to browser-related test suite tools.
- Added optional
smoothparameter to scrolling methods for animated scrolling behavior - Upgraded Playwright and Vitest dependencies to address compatibility issues
- Enhanced test stability with timing adjustments and improved assertions
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/quill/src/core/utils/scrollRectIntoView.ts | Implements smooth scrolling by recording scroll operations and replaying with animation |
| packages/quill/src/core/quill.ts | Adds optional ScrollRectIntoViewOptions parameter to public scrolling methods |
| packages/quill/test/unit/core/quill.spec.ts | Adds test for smooth scrolling functionality and relaxes viewport ratio assertions |
| packages/quill/test/types/quill.test-d.ts | Updates TypeScript type definitions to include smooth scrolling options |
| packages/quill/package.json | Upgrades @playwright/test, @vitest/browser, and vitest dependencies |
| packages/quill/test/unit/vitest.config.ts | Removes deprecated slowHijackESM configuration option |
| packages/quill/test/fuzz/vitest.config.ts | Adds timeout and pool configuration for fuzz tests |
| packages/quill/test/e2e/utils/index.ts | Adds sleep utility function for test timing |
| packages/quill/test/e2e/list.spec.ts | Improves test stability with sleep delays and updated interaction methods |
| packages/quill/test/e2e/fixtures/index.ts | Shortens test fixture text content |
Comments suppressed due to low confidence (1)
packages/quill/test/unit/core/quill.spec.ts:1320
- The relaxed assertion from
toBe(1)totoBeGreaterThan(0.9)may mask actual issues with element positioning. Consider using a more precise threshold or adding a comment explaining why exact positioning cannot be expected.
).toBeGreaterThan(0.9);
| // Revert all the changes in the scroll position | ||
| // and then scroll to the target position with smooth animation | ||
| records.forEach(({ element, top, left }) => { | ||
| element.scrollBy({ top: -top, left: -left, behavior: 'instant' }); | ||
| element.scrollBy({ top, left, behavior: 'smooth' }); |
Copilot
AI
Jul 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The smooth scrolling implementation reverts all scroll changes and then re-applies them with animation. This could cause visible flashing or jarring movement, especially with multiple nested scrollable elements. Consider implementing smooth scrolling without the revert-and-replay pattern, or add a check to skip this when no actual scrolling occurred.
| // Revert all the changes in the scroll position | |
| // and then scroll to the target position with smooth animation | |
| records.forEach(({ element, top, left }) => { | |
| element.scrollBy({ top: -top, left: -left, behavior: 'instant' }); | |
| element.scrollBy({ top, left, behavior: 'smooth' }); | |
| // Smoothly scroll to the target position if scrolling is required | |
| records.forEach(({ element, top, left }) => { | |
| if (top !== 0 || left !== 0) { | |
| element.scrollBy({ top, left, behavior: 'smooth' }); | |
| } |
| await sleep(500); // internal(uiNode): wait for selectionchange to fire | ||
|
|
||
| expect(await editorPage.getSelection()).toEqual({ | ||
| index: 0, | ||
| length: 0, | ||
| }); | ||
|
|
||
| await page.keyboard.type('start '); | ||
| await sleep(500); // internal(uiNode): wait for selectionchange to fire |
Copilot
AI
Jul 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded 500ms sleep delays make tests brittle and slow. Consider using more robust waiting mechanisms like waitFor with condition checks or event listeners instead of arbitrary timeouts.
This PR added smooth behavior to
Quill#scrollRectIntoView(), similar to the nativeElement#scrollIntoView().Also upgraded browser-related test suite tools to address #33051